package leetcode.code0744;

import leetcode.IDebug;

public class Solution implements IDebug {

	public char nextGreatestLetter(char[] letters, char target) {
		int len = letters.length;
		if (target >= letters[len - 1]) {
			return letters[0];
		}
		int l = 0, r = len - 1;
		int ans = 0;
		while (l <= r) {
			int mid = l + ((r - l) >> 1);
			if (letters[mid] > target) {
				ans = mid;
				r = mid - 1;
			} else {
				l = mid + 1;
			}
		}
		return letters[ans];
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
